package com.demo.config;

import com.demo.interceptor.UserInterceptor;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Auther: luobiao
 * @Date: 2020/5/23 09:25
 * @Description:
 */
@Configuration
public class MvcConfig  implements WebMvcConfigurer {

    //拦截器注册方式一
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInterceptor()).addPathPatterns("/user/add");
    }

   /* //拦截器注册方式二
    @Bean
    public MappedInterceptor mappedInterceptor(){
        String[] includePath={"/user/add"};
        MappedInterceptor mappedInterceptor = new MappedInterceptor(includePath, new UserInterceptor());
        return mappedInterceptor;
    }*/

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp("/WEB-INF/jsp/", ".jsp");
    }


}
